#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QWidget>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QLineEdit>
#include <QLabel>
#include <QListWidget>
#include <QCheckBox>

#include "graphicsimageitem.h"

class QPushButton;
class QGraphicsScene;
class QGraphicsView;
class QSlider;

const int IMGWIDTH = 1920;
const int IMGHEIGHT = 1080;
const int ROWBYTES = IMGWIDTH*2;

class MainWindow : public QWidget
{
    Q_OBJECT
    
public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();

signals:
    void updateFrame(off64_t value);

private:
    void initWindow();
    void initScene();
    void resetFrameSlider(int minValue, int maxValue);

    QHBoxLayout *mainHLayout;
    QVBoxLayout *sceneVLayout;
    QHBoxLayout *pathHLayout;
    QPushButton *btnLoad;
    QGraphicsScene *captureScene;
    QGraphicsView *captureView;
    QSlider *sliderFrames;

    // Modified by Lin EST 2012-12-20
    QPushButton *btnCheckTC;
    QStringList *filesListStr;
    // Modified by Lin EST 2013-1-29
    QPushButton *btnSaveImages;
    QPushButton *btnSelectFolder;
    QPushButton *btnSave2StdRaw;
    QLineEdit *saveImagesPath;
    QLineEdit *ledStartFrame;
    QLineEdit *ledFrameNo;
    QLineEdit *ledGoFrame;
    QPushButton *btnGoFrame;

    QCheckBox *cbxAllFrames;
    QCheckBox *cbxAllVideos;
    QCheckBox *cbxExiImages;
    QLabel *lbImagesPath;
    QPushButton *btnCreateVideo;

    QLabel *lbTotalFrames;
    QLabel *lbFirstFrame;
    QLabel *lbLastFrame;

    QListWidget *lswVideoList;
    QPushButton *btnAddVideo;
    QPushButton *btnRemoveVideo;
    QHBoxLayout *listBtnHLayout;
    QVBoxLayout *listVLayout;

    QLabel *lbStatus;

    GraphicsImageItem *gii;

public slots:
    void onCheckTCClicked();
    void onSaveImagesClicked();
    void onSelectFolderClicked();
    void onSave2StdRawClicked();
    void onFrameSliderUpdated(int value);
    void onAddVideoClicked();
    void onRemoveVideoClicked();
    void onLoadVideo(QString videoFile);
    void onAllFramesToggled(bool flag);
    void onCreateVideoClicked();
    // Code above was modified by Lin
};

#endif // MAINWINDOW_H
